﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data;

namespace StatisticLeague
{
    public class DBfacade
    {
    

        public string connectionstring = @"Server=(localdb)\v11.0;Integrated Security=true;AttachDbFileName=C:\Users\Talk2me\Documents\Visual Studio 2012\Projects\StatisticLeague\StatisticLeague\StatisticLeague\Statistic.League.mdf;";
            //@"{Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Talk2me\Documents\Visual Studio 2012\Projects\StatisticLeague\StatisticLeague\StatisticLeague\Statistic.League.mdf;Integrated Security=True";
            //@"Server=(localdb)\v11.0;Integrated Security=true;AttachDbFileName=C:\Users\~\Documents\Visual Studio 2012\Projects\StatisticLeague\StatisticLeague\StatisticLeague\Statistic.League.mdf;";
        public string query = "Select * From [Score]";
            //"Select Game_date, Game_time, Champion_name, Role_name, Champion_kill, Champion_deaths,Champion_assists,Champion_cs, Game_result From Scores Inner join Champions on Scores.Champion_id=Champions.Champion_id Inner join Roles on Scores.Champion_role=Roles.Role_id";

        public string query2 = "select Champion_id, Champion_name From Champions";
        
      
        
        
        public DataTable DBview( string _query)
        {
            query = _query;

              DataTable DBt = new DataTable();
              using (SqlConnection connect = new SqlConnection(connectionstring))
              {
                  connect.Open();
                  using (SqlCommand command = new SqlCommand(query, connect))
                  {
                      SqlDataAdapter da = new SqlDataAdapter(command);
                      da.Fill(DBt);
                  }
              }

            return DBt;

        }




        
        public DataTable ChampionsDB()
        {
            DataTable DTS = new DataTable();
            using (SqlConnection connect = new SqlConnection(connectionstring))
            {
                connect.Open();
                using (SqlCommand command = new SqlCommand(query2, connect))
                {
                    SqlDataAdapter da = new SqlDataAdapter(command);
                    da.Fill(DTS);
                }
            }

            return DTS;

        }

    }
}
